﻿using System;
using System.Text;
using Petra.Gis.Geometry;
using Petra.Gis.DataServices.MSSQL10;


namespace testDataServices
{
  public class MSSQL10
  {



    public static void testInMem()
    {
      byte[] b;
      GeometryBase g;

      GeometryFactory conv = new GeometryFactory();

      b = HexStrToByteArray("0x00000000 010C 000000000000F03F 000000000000F03F");
      g = conv.CreateGeometry(b);

      b = HexStrToByteArray("0x00000000 010D 000000000000F03F 0000000000000040 000000000000F03F");
      g = conv.CreateGeometry(b);

      b = HexStrToByteArray("0x00000000 010F 000000000000F03F 0000000000000040 000000000000F03F 0000000000000040");
      g = conv.CreateGeometry(b);

    }






    static string ByteArrayToString(byte[] ba)
    {
      StringBuilder hex = new StringBuilder(ba.Length * 2);
      foreach (byte b in ba)
        hex.AppendFormat("{0:X2}", b);
      return hex.ToString();
    }



    static byte[] HexStrToByteArray(string hexStr)
    {

      hexStr = hexStr.Replace(" ", "");
      hexStr = hexStr.Replace("0x", "");

      byte tmp;

      byte[] b = new byte[hexStr.Length / 2];
      for (int i = 0; i < hexStr.Length; i += 2)
      {
        tmp = byte.Parse(hexStr.Substring(i, 2), System.Globalization.NumberStyles.HexNumber);
        b[i / 2] = tmp;
      }
      return b;
    }


  }

}
